﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrismRegion.Journal.ViewModels
{
    public class ViewCViewModel:INavigationAware
    {
        public DelegateCommand GoBackCommand { get; set; }
        public DelegateCommand ForwordCommand { get; set; }
        IRegionNavigationJournal journal { get; set; }
        public ViewCViewModel(IRegionManager regionManager)
        {
            GoBackCommand = new DelegateCommand(() => {
                if (journal.CanGoBack)
                {
                    journal.GoBack();
                }
            });
            ForwordCommand = new DelegateCommand(() => {
                if (journal.CanGoForward)
                {
                    journal.GoForward();
                }
                else {
                    regionManager.RequestNavigate("MainRegion", "ViewA");
                }
            });
        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            journal = navigationContext.NavigationService.Journal;
        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
        }
    }
}
